<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>流程图设计</title>
<!--[if lt IE 9]>
<?import namespace="v" implementation="#default#VML" ?>
<![endif]-->
<!--<link rel="stylesheet" type="text/css" href="codebase/GooFlow2.css"/>-->
<link rel="stylesheet" type="text/css" href="codebase/GooFlow.css"/>
<style>
.myForm{display:block;margin:0px;padding:0px;line-height:1.5;border:#ccc 1px solid;font: 12px Arial, Helvetica, sans-serif;margin:5px 5px 0px 0px;border-radius:4px;}
.myForm .form_title{background:#428bca;padding:4px;color:#fff;border-radius:3px 3px 0px 0px;}
.myForm .form_content{padding:4px;background:#fff;}
.myForm .form_content table{border:0px}
.myForm .form_content table td{border:0px}
.myForm .form_content table .th{text-align:right;font-weight:bold}
.myForm .form_btn_div{text-align:center;border-top:#ccc 1px solid;background:#f5f5f5;padding:4px;border-radius:0px 0px 3px 3px;} 
#propertyForm{float:right;width:260px}
</style>
<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript" src="../GooFunc.js"></script>
<script type="text/javascript" src="../json2.js"></script>
<script src="/IE-MES/js/layer-v1.9.2/layer/layer.js"></script>
<link rel="stylesheet" type="text/css" href="../default.css"/>
<script type="text/javascript" src="codebase/GooFlow.js"></script>
<script type="text/javascript">

function getJsonObjLength(jsonObj) {
  var Length = 0;
  for (var item in jsonObj) {
    Length++;
  }
  return Length;
}

function onLoadSuccess(e){
	//添加数据
	var j = JSON.parse(e);
	demo.loadData(JSON.parse(j.data));
	$('#process_route').val(j.process_route);
	//$('#process_route_type').val(j.process_route_type);
	$('#process_route_desc').val(j.process_route_desc);
	$('#id').val(j.id);
}

function onLoadError(){
	alert("err");
}


$(document).ready(function(){
	$("form").submit(function(e) {
		document.getElementById("data").value = JSON.stringify(demo.exportData());
		var datastr = JSON.stringify(demo.exportData());
		var jsonobj = JSON.parse(datastr);
		var nodesLen = getJsonObjLength(jsonobj.nodes);
		var linesLen = getJsonObjLength(jsonobj.lines);
		if(linesLen==0 && nodesLen>1){
			layer.alert("节点必须连接");
			return false;
		}
		if(linesLen<(nodesLen-1)){
			layer.alert("不可存在未连接节点");
			return false;
		}
		var form = document.getElementById('propertyForm');
		if (form.process_route.value=="") {
			layer.alert("工艺路线不能为空");
			return false;
		}
		if (form.process_route_desc.value=="") {
			layer.alert("工艺路线描述不能为空");
			return false;
		}
		
	    $.ajax({ type: 'POST', data: $(this).serialize(), url: '/IE-MES/workshop/routing_editEntity.shtml',
	        success: function () {
	        	parent.grid.loadData();
	        	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
	        	parent.layer.close(index);
	        },
	        error: function (xhr) {
	        	layer.alert("哎呀，好像出错了！");
	        } 
	    });
	    return false;
	});
});


var property={
	width:$(window).width()-280,
	height:$(window).height()-50,
	toolBtns:[],
	haveHead:true,
	headBtns:["undo","redo","reload"],//如果haveHead=true，则定义HEAD区的按钮
	haveTool:true,
	haveGroup:true,
	useOperStack:true
};
var remark={
	cursor:"选择指针",
	direct:"转换连线",
	start:"开始结点",
	end:"结束结点"
};
var demo;
$(document).ready(function(){
	
	demo=$.createGooFlow($("#demo"),property);
	demo.setTitle("工艺路线修改");
	//设置左边的按钮
	demo.setNodeRemarks(remark);
	
	var process_route = window.parent.grid.selectRow()[0].process_route;
	var queryParam = {
			"type": "get", 
			"url": "/IE-MES/workshop/routing_queryData.shtml?process_route=" + process_route, 
			"success": onLoadSuccess, 
			"error": onLoadError
	};
	demo.loadDataAjax(queryParam);
	//清除
	demo.onFreshClick = function () {
		demo.clearData();
    }
	
	
});
</script>
</head>
<body style="background:#EEEEEE">
<div id="demo" style="margin:5px;float:left"></div>
<form class="myForm" method="post" name="propertyForm" id="propertyForm" action="">
<div class="form_title">属性设置</div>
<div class="form_content">
  <table>
    <tr><td class="th"><font color="red">*</font>工艺路线：</td><td><input type="text" style="width:120px" name="routingFormMap.process_route" id="process_route"/></td></tr>
    <tr><td class="th">工艺路线描述：</td><td><input type="text" style="width:120px" name="routingFormMap.process_route_desc" id="process_route_desc"/></td></tr>
    <tr><td class="th"><font color="red">*</font>状态：</td><td>
    
    <select name="routingFormMap.state" id="state">
		<option value ="1">可用</option>
	  	<option value ="0">不可用</option>
	</select>
	
    </td></tr>
    <tr><td class="th"><font color="red">*</font>是否允许跳过：</td><td>
    
    <select name="routingFormMap.allowpass" id="allowpass">
		<option value ="1">不跳过</option>
	  	<option value ="0">跳过</option>
	</select>
    <input type="hidden" id="id" name="routingFormMap.id"/>
    </td></tr>
    <input type="hidden" style="width:120px" name="routingFormMap.data" id="data" value="123"/>
  </table>
</div>
<div class="form_btn_div">
  <input type="reset" value="重置"/>
  <input type="submit" value="保存"/>
</div>
</form>
</body>
</html>